using System.Collections.ObjectModel;
using HMCollada.FX;
using System.Xml;
using HMCollada.Core;

namespace HMCollada.Core {
    internal struct HMColladaTechniqueCommon {
        internal HMColladaAccessor accessor;
        internal Collection<HMColladaInstanceMaterial> instance_material;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaTechniqueCommon LoadTechniqueCommon() {
            HMColladaTechniqueCommon newTechniqueCommon = new HMColladaTechniqueCommon();

            newTechniqueCommon.instance_material = new Collection<HMColladaInstanceMaterial>();

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "accessor": newTechniqueCommon.accessor = LoadAccessor(); break;
                        case "instance_material": newTechniqueCommon.instance_material.Add(LoadInstanceMaterial()); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "technique_common");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newTechniqueCommon;
        }
    }
}